(function(){"use strict";BX.namespace("BX.Grid");BX.Grid.PinPanel=function(t){this.parent=null;this.panel=null;this.isSelected=null;this.offset=null;this.animationDuration=null;this.pinned=false;this.init(t)};BX.Grid.PinPanel.prototype={init:function(t){this.parent=t;this.offset=10;this.animationDuration=200;this.panel=this.getPanel();this.bindOnRowsEvents()},bindOnRowsEvents:function(){BX.addCustomEvent("Grid::thereSelectedRows",BX.delegate(this._onThereSelectedRows,this));BX.addCustomEvent("Grid::allRowsSelected",BX.delegate(this._onThereSelectedRows,this));BX.addCustomEvent("Grid::noSelectedRows",BX.delegate(this._onNoSelectedRows,this));BX.addCustomEvent("Grid::allRowsUnselected",BX.delegate(this._onNoSelectedRows,this));BX.addCustomEvent("Grid::updated",BX.delegate(this._onNoSelectedRows,this))},bindOnWindowEvents:function(){BX.bind(window,"resize",BX.proxy(this._onResize,this));document.addEventListener("scroll",BX.proxy(this._onScroll,this),BX.Grid.Utils.listenerParams({passive:true}))},unbindOnWindowEvents:function(){BX.unbind(window,"resize",BX.proxy(this._onResize,this));document.removeEventListener("scroll",BX.proxy(this._onScroll,this),BX.Grid.Utils.listenerParams({passive:true}))},getPanel:function(){this.panel=this.panel||this.parent.getActionsPanel().getPanel();return this.panel},getScrollBottom:function(){return BX.scrollTop(window)+this.getWindowHeight()},getPanelRect:function(){if(!BX.type.isPlainObject(this.panelRect)){this.panelRect=BX.pos(this.getPanel())}return this.panelRect},getPanelPrevBottom:function(){var t=BX.previousSibling(this.getPanel());return BX.pos(t).bottom+parseFloat(BX.style(t,"margin-bottom"))},getWindowHeight:function(){this.windowHeight=this.windowHeight||BX.height(window);return this.windowHeight},pinPanel:function(t){var e=this.getPanel();var i=BX.width(this.getPanel().parentNode);var n=BX.height(this.getPanel().parentNode);var s=BX.pos(this.parent.getBody());var o=this.getStartDiffPanelPosition();e.parentNode.style.setProperty("height",n+"px");e.style.setProperty("transform","translateY("+o+"px)");e.classList.add("main-grid-fixed-bottom");e.style.setProperty("width",i+"px");e.style.removeProperty("position");e.style.removeProperty("top");requestAnimationFrame(function(){if(t!==false){e.style.setProperty("transition","transform 200ms ease")}e.style.setProperty("transform","translateY(0)")});if(this.isNeedPinAbsolute()&&!this.absolutePin){this.absolutePin=true;e.style.removeProperty("transition");e.style.setProperty("position","absolute");e.style.setProperty("top",s.top+"px")}if(!this.isNeedPinAbsolute()&&this.absolutePin){this.absolutePin=false}this.adjustPanelPosition();this.pinned=true},unpinPanel:function(t){var e=this.getPanel();var i=BX.pos(e);var n=BX.pos(e.parentNode);var s=Math.abs(i.bottom-n.bottom);if(t!==false){e.style.setProperty("transition","transform 200ms ease")}var o=s<i.height?s+"px":"100%";e.style.setProperty("transform","translateY("+o+")");var r=function(e,i){if(t!==false){return setTimeout(e,i)}e()};r(function(){e.parentNode.style.removeProperty("height");e.classList.remove("main-grid-fixed-bottom");e.style.removeProperty("transition");e.style.removeProperty("transform");e.style.removeProperty("width");e.style.removeProperty("position");e.style.removeProperty("top")},t!==false?200:0);this.pinned=false},isSelectedRows:function(){return this.isSelected},isNeedPinAbsolute:function(){return BX.pos(this.parent.getBody()).top+this.getPanelRect().height>=this.getScrollBottom()},isNeedPin:function(){return this.getScrollBottom()-this.getPanelRect().height<=this.getPanelPrevBottom()},adjustPanelPosition:function(){var t=window.pageXOffset;this.lastScrollX=this.lastScrollX!==null?this.lastScrollX:t;BX.Grid.Utils.requestAnimationFrame(BX.proxy(function(){if(t!==this.lastScrollX){var e=this.getPanelRect();BX.style(this.getPanel(),"left",e.left-t+"px")}},this));this.lastScrollX=t},pinController:function(t){if(this.getPanel()){if(!this.isPinned()&&this.isNeedPin()&&this.isSelectedRows()){return this.pinPanel(t)}if(this.isPinned()&&!this.isNeedPin()||!this.isSelectedRows()){this.unpinPanel(t)}}},getEndDiffPanelPosition:function(){var t=BX.pos(this.getPanel());var e=BX.pos(BX.previousSibling(this.getPanel()));var i=BX.scrollTop(window);var n=i+BX.height(window);var s=t.height+this.offset;var o=e.bottom+parseFloat(BX.style(this.getPanel(),"margin-top"));if(o<n&&o+t.height>n){s=Math.abs(n-(o+t.height))}return s},getStartDiffPanelPosition:function(){var t=BX.pos(this.getPanel());var e=BX.scrollTop(window);var i=e+BX.height(window);var n=t.height;if(t.bottom>i&&t.top<i){n=t.bottom-i}return n},isPinned:function(){return this.pinned},_onThereSelectedRows:function(){this.bindOnWindowEvents();this.isSelected=true;if(this.lastIsSelected){this.pinController()}else{this.lastIsSelected=true;this.pinController()}},_onNoSelectedRows:function(){this.unbindOnWindowEvents();this.isSelected=false;this.pinController();this.lastIsSelected=false},_onScroll:function(){this.pinController(false)},_onResize:function(){this.windowHeight=BX.height(window);this.panel=this.parent.getActionsPanel().getPanel();this.panelRect=this.getPanel().getBoundingClientRect();this.pinController(false)}}})();
//# sourceMappingURL=pin-panel.map.js